home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / COBOL / H309.ZIP / PSICO.ZIP / PSICO12.EXE / PSICO.DOC < prev    next >
Text File  |  1993-02-12  |  34KB  |  1,057 lines

  1.  
  2. ----------------------------------------------------------------------------
  3.  
  4.                              PSICO USER GUIDE
  5.                                 VERSION 1.2
  6.  
  7. ----------------------------------------------------------------------------
  8.  
  9.  
  10.  
  11. CONTENTS
  12.  
  13.  
  14.  
  15. Chapter 1. Introduction
  16.  
  17. Chapter 2. Functions
  18.  
  19. Chapter 3. Menu commands
  20.  
  21. Chapter 4. Automatic demonstration mode
  22.  
  23. Chapter 5. Parameters and notes
  24.  
  25. Chapter 6. COBOL techniques and style
  26.  
  27. Chapter 7. Structured COBOL
  28.  
  29. Chapter 8. Online Help
  30.  
  31. Chapter 9. Future versions
  32.  
  33. Appendix A. Reformatting Table definition
  34.  
  35. Appendix B. Structure syntax
  36.  
  37. Appendix C. Example of structured COBOL program
  38.  
  39.  
  40.  
  41. ----------------------------------------------------------------------------
  42.  
  43.                                CHAPTER ONE
  44.  
  45. ----------------------------------------------------------------------------
  46.  
  47. INTRODUCTION
  48.  
  49. This  program  is  a  utility  which  is  intended  to  assist  in creating
  50. structured COBOL  source  code.  It  presents  to  the  user  a  series  of
  51. templates, which are then used to generate files containing working storage
  52. and procedure code.
  53.  
  54. The  code  generated by the structure commands is restricted to a subset of
  55. the full ANS85 COBOL, but should cover most  requirements.  The  facilities
  56. provided are believed to be compatible with many different COBOL compilers,
  57. from PC to mainframe. However, it may in some circumstances be necessary to
  58. edit the generated program to remove incompatibilities.
  59.  
  60. At  the  end  of the run, the files created are merged to create a complete
  61. source file. This source  can  be  in  one  of  two  formats  chosen  by  a
  62. command-line parameter:
  63.  
  64.    MODE=C generates ANS85 COBOL source with file extension .CBL
  65.    MODE=S generates source code in our own structured format, with
  66.           file extension .STR
  67.  
  68. A  source file generated in our own format must then be preprocessed by our
  69. COBFORM utility to expand the special structure verbs into ANS74 COBOL.
  70.  
  71. Note that ANY dialect of COBOL may be used, from the UTAH subset up to full
  72. ANS85 COBOL such as Micro Focus COBOL/2.
  73.  
  74. In accordance with good practice,  the  program  design  should  have  been
  75. completed  in  a  structured  format before using PSICO to enter the source
  76. code.
  77.  
  78. Extra facilities for registered users
  79. -------------------------------------
  80.  
  81. None as yet. The full mainframe version contains a built-in editor, but I
  82. have had stack overflow problems when trying to convert it to the PC.
  83.  
  84.  
  85. ----------------------------------------------------------------------------
  86.  
  87.                                 CHAPTER TWO
  88.  
  89. -----------------------------------------------------------------------------
  90.  
  91. FUNCTIONS
  92. ---------
  93.  
  94. Initial process
  95. ---------------
  96.  
  97. The program requires a program name as a command-line parameter. This is up
  98. to  8  characters  long, and will be used for the PROGRAM-ID as well as the
  99. names of all output files.
  100.  
  101. Note that all files must be held in the current directory.
  102.  
  103. The  program  creates  skeleton  IDENTIFICATION,   ENVIRONMENT   and   DATA
  104. divisions. These can be edited later if necessary.
  105.  
  106. Procedure processing
  107. --------------------
  108.  
  109. The  program  processes  one  procedure at a time. A procedure is one COBOL
  110. SECTION.
  111.  
  112. The Procedure screen accepts the  details  for  the  first  procedure.  The
  113. default  name can be replaced, and any other details specified (see Chapter
  114. 5 and Appendix B for description of the various parameters).
  115.  
  116. We recommend that you set CAPS LOCK on, because all keywords  used  in  the
  117. program  must  be in UPPER case. This is, of course, for compatibility with
  118. COBOL.
  119.  
  120.     At this point, I should warn you that the program has been converted
  121.     from an ICL VME program, and the screen processing is based on an
  122.     emulation of the ICL mainframe terminals.
  123.  
  124.     Only the text in unprotected areas from the start of the screen up to
  125.     the cursor position is accepted, and any data to the right of or below
  126.     the cursor position is ignored. The unprotected areas are delimited by
  127.     left and right pointing arrows. A fuller description of the keyboard
  128.     usage is given in appendix D.
  129.  
  130. When finished, press ENTER. A Comment box will then be displayed for you to
  131. complete. Any text  typed  will  be  included  as  COBOL  comments  in  the
  132. generated program.
  133.  
  134. To  end  the  program,  type  N (Upper case only) in the More? field on the
  135. procedure screen. You can only exit from the program at a PROCEDURE screen.
  136. Although you can quit at any time using the ESCape key, this  abandons  the
  137. processing, and does not create the output program.
  138.  
  139.  
  140.  
  141.  
  142. Structure processing
  143. --------------------
  144.  
  145. The program will display a SEQUENCE structure screen as the first screen
  146. within a procedure. You may type any COBOL code within the main ('action')
  147. body of the screen, with the leftmost column corresponding to COBOL area B.
  148.  
  149. Special features:
  150.  
  151.    If you type an asterisk (*) in the first column, the line will be taken
  152.    as a COBOL comment line.
  153.  
  154.    If you type @ in the first column, the line will be taken as a data
  155.    item, and written to the WORKING-STORAGE SECTION. This is a very
  156.    useful facility, allowing you to define data items while entering
  157.    procedure code.
  158.  
  159. For the time being, ignore the field at the top marked 'Menu'. This is used
  160. for other commands described below.
  161.  
  162. When the page is filled, press Enter, and the next screen will be
  163. displayed. When you have entered all the code for the sequence, type N in
  164. the field named 'More'.
  165.  
  166. So far, this may not seem to be very useful. But you can also enter
  167. structure commands, which trigger different types of screen.
  168.  
  169. The structures available are:
  170.      SEQ        the default (sequence) structure
  171.      WHILE      ) loop structures
  172.      UNTIL      )
  173.      SELECT     Multi-choice condition structure
  174.      POSIT      Special JSP structure (not available if mode = C)
  175.      ZIF        generates an IF-THEN-ELSE structure
  176.      ZREAD      generates a READ .... AT END .... structure
  177.      BOX        generates a comment box
  178.  
  179. A structure command must be coded on a separate line, and anything else on
  180. that line will be ignored. It may be used within the action body of any
  181. structure, with certain exceptions described below.
  182.  
  183. If, within a SEQUENCE, you type WHILE on the first body line, and UNTIL on
  184. the second, then you will be presented with a WHILE screen, and then when
  185. completed, an UNTIL screen. The screens are presented in a top-down
  186. sequence, ie within the UNTIL, you can code another structure, perhaps a
  187. SELECT, which will be completed before the UNTIL is ended.
  188.  
  189. As each structure is completed, the source code is copied out of the stack
  190. into the output file.
  191.  
  192.  
  193. ZIF, WHILE and UNTIL structures
  194. -------------------------------
  195.  
  196. As well as the Menu field and action body lines, a condition line is
  197. present. A COBOL condition should be entered here. If there is not enough
  198. space, enter a >, and press Enter. An extended condition screen will be
  199. provided.
  200.  
  201. There are only 10 lines in the body of the WHILE. If this is not enough,
  202. enter  SEQ to create a sequence  structure. Any number of lines may be
  203. included in a sequence.
  204.  
  205. If MODE=C, a PERFORM UNTIL statement is generated, with the condition
  206. reversed if the structure is a WHILE loop.
  207.  
  208. ZIF structure
  209. -------------
  210.  
  211. This is an IF-THEN-ELSE structure. If generating ANS85 COBOL, ie MODE=C,
  212. then further structures can be nested inside it. This is not possible if
  213. MODE=S, (except for a SEQUENCE structure) and you should use the SELECT
  214. structure instead.
  215.  
  216. ZREAD structure
  217. ---------------
  218.  
  219. This is READ-AT-END structure. If generating ANS85 COBOL, ie MODE=C,
  220. then further structures can be nested inside it. This is not possible if
  221. MODE=S, and you should use a flag field, and follow the READ by a SELECT
  222. structure instead if that facility is required.
  223.  
  224. SELECT structure
  225. ----------------
  226.  
  227. A  CASE screen is displayed, which contains a condition and an action body.
  228. At the top, a field is present marked 'More cases?'. This should be set  to
  229. N when all cases have been entered, otherwise a further CASE screen will be
  230. displayed. Up to 9,999 cases are allowed in a single SELECT structure.
  231.  
  232. As  well  as  the  Menu  field  and  action body lines, a condition line is
  233. present. A COBOL condition should be entered here. If there is  not  enough
  234. space,  enter  a  >,  and press Enter. An extended condition screen will be
  235. provided.
  236.  
  237. The condition may be left blank on the last CASE screen, to act as an  ELSE
  238. condition. This will automatically terminate the SELECT structure.
  239.  
  240. If MODE=C, a COBOL EVALUATE statement will be generated, with a WHEN clause
  241. for each specified CASE.
  242.  
  243. Textual substitution
  244. --------------------
  245.  
  246. Available only if MODE=S
  247.  
  248. This is performed by the preprocessor COBFORM, which uses a table, held in
  249. an ASCII text file, to specify any substitutions required. See the COBFORM
  250. User Guide for details.
  251.  
  252.  
  253.  
  254. ----------------------------------------------------------------------------
  255.  
  256.                                 CHAPTER THREE
  257.  
  258. ----------------------------------------------------------------------------
  259. Menu commands
  260.  
  261. The Menu command field, which appears on most structure screens, is used to
  262. implement various out-of-line processes, such as  defining  a  COBOL  file.
  263. The following commands are currently available, although more are planned:
  264.  
  265. ?       Display menu of commands
  266.  
  267. F       Define a file
  268.         This provides a single screen on which you can enter the
  269.         SELECT  statement, the FD and a data record. These are then written
  270.         to the appropriate COBOL sections.
  271.  
  272. L       Define a linkage data item
  273. W       Define a working storage data item
  274.  
  275.         W and L allow easy entry of individual data items
  276.  
  277. -       Up one level in the stack
  278. +       Down one level
  279.  
  280.         The current nest of structures is held in a stack, with the top  of
  281.         stack being the outermost level, which is always a SEQUENCE.
  282.         These  commands  allow  you  to  backtrack and change what has been
  283.         entered. Since the code is written to files  at  the  end  of  each
  284.         screen,  you  can  only  change  lines  which  have  not  yet  been
  285.         processed. The current structure is indicated,  and  you  can  only
  286.         change lines BELOW it on the screen.
  287.  
  288.  
  289.  
  290.  
  291. ----------------------------------------------------------------------------
  292.  
  293.                                 CHAPTER FOUR
  294.  
  295. ----------------------------------------------------------------------------
  296. Automatic demonstration mode
  297. ----------------------------
  298.  
  299. The program contains facilities to record and play back a sequence of
  300. keystrokes, in order to create demonstration disks.
  301.  
  302. The following keys are used to control these facilities:
  303.  
  304.    F7      Starts  recording. This is ALWAYS into a file called PLAY.ASK in
  305.            the current directory
  306.    F8      Stops recording
  307.    F4      Inserts a pause, waiting for a key to be pressed
  308.    F6      Press this to start playback of file PLAY.ASK
  309.  
  310. After  recording,  it  is  advisable to rename PLAY.ASK, to some other name
  311. because it will otherwise be overwritten next time you record a session.
  312.  
  313. During the playback
  314.  
  315.    F (Faster)   Speeds up the playback, as far as possible. The playback
  316.                 always starts at maximum speed
  317.    S (Slower)   Slows down the playback
  318.    Esc          The ESC key returns to DOS at any time during the playback
  319.  
  320. PSICO can use a command line parameter to specify a different script  file.
  321. I have used extension ASK for scripts, but this is not mandatory.  A script
  322. file  MATCH3.ASK  is  included in the released software, which will produce
  323. either a COBOL85 or a COBFORM demonstration source file  depending  on  the
  324. MODE parameter used.
  325.  
  326. Type   PSICO MATCH3 MODE=C PLAY=MATCH3.ASK  for COBOL85
  327. Type   PSICO MATCH3 MODE=S PLAY=MATCH3.ASK  for COBFORM
  328.  
  329. Then you can compare the output files MATCHN.CBL, MATCHN.STR.
  330.  
  331. MATCH3.STR, when processed by COBFORM, is compatible with the shareware
  332. COBOL600 compiler. MATCH3.CBL is compatible with MicroFocus COBOL/2
  333.  
  334.  
  335.  
  336. ----------------------------------------------------------------------------
  337.  
  338.                                 CHAPTER FIVE
  339.  
  340. ----------------------------------------------------------------------------
  341.  
  342. Parameters
  343. ----------
  344.  
  345. The keywords do not need to be given if the parameters are given in the
  346. correct order as follows:
  347.  
  348. KEYWORD    MEANING
  349. =======    =======
  350. PROG=      You must enter the program-id. There is no default.
  351.  
  352. MODE=      C for ANS85 COBOL, S for COBFORM source. Default is S
  353.  
  354. PLAY=      Use this to play back a prerecorded script.
  355.  
  356.            You can either specify the script file name, or PLAY=Y to use
  357.            the default file PLAY.ASK. Default is space (ie no playback).
  358.  
  359.            If the script file does not exist, the parameter is ignored.
  360.  
  361. ALL PARAMETERS MUST BE IN UPPER CASE!!!! Best to set the caps lock on first.
  362.  
  363. EXAMPLES:
  364.  
  365.     PSICO MATCH3  C
  366.     PSICO MATCH3  PLAY=Y  MODE=S
  367.     PSICO MATCH3  PLAY=MATCH.ASK
  368.  
  369.  
  370.  
  371. ----------------------------------------------------------------------------
  372.  
  373.                                  CHAPTER SIX
  374.  
  375. ----------------------------------------------------------------------------
  376. COBOL techniques and style:   Some ideas on programming in COBOL85
  377.  
  378. Maintainability
  379. ===============
  380. In  most  commercial use, more time is spent maintaining a program over its
  381. lifetime than is taken to write it. Therefore ease of maintenance should be
  382. a prime concern. This was one of the  main  reasons  for  the  adoption  of
  383. Structured Programming techniques.
  384.  
  385.  
  386. Data definitions
  387. ================
  388. In  the  old  days of COBOL, lots of complex data structures, with multiple
  389. redefinitions, were the norm, particularly in print  programs.   Since  the
  390. introduction  of  the  STRING  and UNSTRING commands, much of this has been
  391. unnecessary.  However, old habits die hard, and this style of code is still
  392. to be seen in many places, including textbooks.
  393.  
  394. Nowadays,  I  NEVER  define  a  print  line in working storage, but use the
  395. STRING statement, with a pointer, to put data  anywhere  in  a  print  line
  396. which  is  defined simply as PIC X(132). My programs are now much FASTER to
  397. write, EASIER to debug, more RESILIANT to  changes  in  print  layout,  and
  398. QUICKER to modify.
  399.  
  400. Numeric data items are moved to standard edited fields, which are held in a
  401. Copylibrary. I use such names as WS-5V2 to mean PIC  ZZ,ZZ9V.99,  for  this
  402. purpose.
  403.  
  404. It is even possible to compute the column numbers in the program, and allow
  405. for different widths of paper.  It is possible to do such useful  tasks  as
  406. calculating  the length of the data, and using it to centre headings - easy
  407. in BASIC, but not in COBOL.
  408.  
  409.  
  410. EXAMPLES:
  411. =========
  412.  
  413.    MOVE SPACES TO PRINT-LINE
  414.    MOVE 1 TO WS-COLUMN
  415.    STRING "TRANTOR LTD" DELIMITED SIZE INTO PRINT-LINE
  416.                         WITH POINTER WS-COLUMN
  417.  
  418.    MOVE 60 TO WS-COLUMN
  419.    STRING "EXAMPLE REPORT" DELIMITED SIZE INTO PRINT-LINE
  420.                         WITH POINTER WS-COLUMN
  421.    MOVE 110 TO WS-COLUMN
  422.    MOVE WS-PAGE TO WS-4V0
  423.    STRING "PAGE "
  424.           WS-4V0
  425.           DELIMITED SIZE INTO PRINT-LINE
  426.                         WITH POINTER WS-COLUMN
  427.  
  428. This  may  seem  like  more  typing,  but  with  any decent editor, you can
  429. duplicate  standard blocks of text, and just replace the changed bits. Just
  430. think of the time saved in  working  out  the  print  line  definitions!
  431.  
  432.  
  433. Using this method, I normally code straight from  the  print  layout.  Each
  434. item  is  individually  placed  on  the  line, and can be realigned without
  435. affecting any other item.
  436.  
  437. Multiple Definitions
  438. ====================
  439.  
  440. One of the main problems when altering a data definition, such as a  record
  441. format,  is  in  tracing  all  the  places  in  which the record data items
  442. are defined.  As well as the definitions in the input, and possibly output,
  443. files,  there are usually working-storage definitions of all or part of the
  444. data.
  445.  
  446. It  is  often  much  better  to define the input and output records as just
  447. simple  buffers,  and make ONE definition in working storage.  Even this is
  448. not absolutely necessary, and I have written generalised programs, such  as
  449. a 'structured record' edit and print, in which the data records are totally
  450. defined  by tables read from a file. In fact, I have also written a program
  451. which  reads  COBOL  data  definitions  to create these tables in the first
  452. place. (A demo version of the editor is available for the PC)
  453.  
  454. The fundamental principle is that a data item  should  be  defined  in  ONE
  455. PLACE ONLY, as far as is possible. The advantages of this approach are that
  456. when, for example, a single data item is changed in size, other code is not
  457. necessarily affected.
  458.  
  459. (To be continued at the next release)
  460.  
  461.  
  462.  
  463. ----------------------------------------------------------------------------
  464.  
  465.                                CHAPTER SEVEN
  466.  
  467. ----------------------------------------------------------------------------
  468.  
  469. Using Structured COBOL (MODE=S only)
  470. ------------------------------------
  471.  
  472. Structure verbs are provided as an extension of the COBOL language.
  473. The syntax is defined in appendix B, as well as some suggestions for
  474. tailoring the language.
  475.  
  476. The normal use of COBOL is not restricted in any way, and structured
  477. procedures may be freely mixed with COBOL sections in the same program.
  478.  
  479.  
  480. Procedures
  481. ----------
  482.  
  483. A structured program is divided into procedures. Each procedure is
  484. equivalent to, and will be expanded into, a COBOL SECTION. A procedure
  485. is invoked by PERFORMing the procedure, using a normal COBOL PERFORM
  486. statement.
  487.  
  488. Three kinds of procedure are provided:
  489.  
  490. Normal
  491. ------
  492.  
  493. This acts as a normal COBOL routine.
  494.  
  495. Recursive
  496. ---------
  497.  
  498. A special verb is provided for the routine to be able to call itself.
  499. Return address processing is automatically provided but the user must
  500. define appropriate working storage for a stack of return addresses
  501. and a stack pointer. See the supplied example for details.
  502.  
  503.  
  504. Multi-state
  505. -----------
  506.  
  507. Multi-state routines, as used in data-driven structured methodologies,
  508. are routines which perform only part of their task on any invocation.
  509. When the routine has finished the current part of the task, it saves
  510. a note of the current position within the processing in a "state variable",
  511. and returns to the calling module. On subsequent reentry, it resumes
  512. at the point immediately following the previous exit.
  513.  
  514. A multi-threading variant is also supported, in which the single state
  515. variable is replaced by an array, and a "thread" variable is also
  516. used, which is a subscript to the array.
  517.  
  518. This type of routine is best left to those familiar with the theory
  519. of its use.
  520.  
  521.  
  522.  
  523.  
  524. Number of routines
  525. ------------------
  526.  
  527. Up to 36 procedures may be specified within one program. It should
  528. be noted that the top-level routine within a program MUST be a normal
  529. procedure, not recursive or multistate. If necessary, a dummy first
  530. procedure could be provided which just PERFORMs the required routine.
  531.  
  532.  
  533. Structures
  534. ----------
  535.  
  536. A number of different types of structure are provided :
  537.  
  538.  
  539. Sequence
  540. --------
  541.  
  542. Within the structure body, statements are executed in the order in
  543. which they are written.
  544.  
  545.  
  546. Selection
  547. ---------
  548.  
  549. The SELECT structure provides any number of conditions, and a structure
  550. body associated with each.
  551.  
  552. Only one body will be actioned, which will be the first encountered
  553. for which the specified condition is true.
  554.  
  555. An ELSE body may also be specified, which will be executed when none
  556. of the specified conditions is true.
  557.  
  558.  
  559. Iteration  (repetition)
  560. ---------
  561.  
  562. The body of the structure is executed repeatedly until the termination
  563. condition is met.
  564.  
  565. Two kinds of iteration are provided :
  566.  
  567.         Iterate until the condition is true
  568.  
  569.         Iterate while the condition is true.
  570.  
  571.  
  572.  
  573. Structures may be nested to a depth of 36, and any type of structure
  574. may be nested within any other.
  575.  
  576. Full specifications of the structure syntax are in Appendix B, and
  577. an example of a structured program using all the facilities described
  578. is given in Appendix C.
  579.  
  580.  
  581.  
  582.  
  583. Using Recursion
  584. ---------------
  585.  
  586. This is a very powerful technique for certain types of program. As
  587. the COBOL language does not support recursive calls, the method has
  588. not been widely used in the commercial DP world, although in languages
  589. such as LISP and PROLOG it is the basic method of processing.
  590.  
  591. A simple routine which uses structured COBOL to build and display
  592. a binary tree is given in Appendix C.
  593.  
  594. Error messages
  595. --------------
  596.  
  597. Error and warning messages are inserted as comments into the output
  598. text, at the place where the error is discovered.
  599.  
  600.  
  601.  
  602. ----------------------------------------------------------------------------
  603.  
  604.                                CHAPTER EIGHT
  605.  
  606. ----------------------------------------------------------------------------
  607.  
  608. Online Help
  609.  
  610. Online help may be obtained from any screen which has a MENU field. To
  611. obtain help on any item, type ? followed by that item, eg ?INSPECT, in the
  612. MENU field and press ENTER
  613.  
  614. Two help files are provided:
  615.       PSHELP.C74 with ANS74 COBOL syntax for mode S
  616.       PSHELP.C85 with ANS85 COBOL syntax for mode C
  617.  
  618. The program will automatically select the correct file depending on the
  619. MODE parameter.
  620.  
  621. The files do not pretend to give a full and rigorous definition of COBOL
  622. syntax, but are intended to give general assistance. They are simple ASCII
  623. text files, and may be edited by the user to add any extra information
  624. required.
  625.  
  626. The conventions used include
  627.    [  ] to bracket optional items
  628.    {  } to enclose multiple choices
  629.    ╠  ╣ to indicate items or clauses which may be repeated.
  630.  
  631. The search key is an @ in the first column followed by the search subject
  632. without intervening space. By default, 21 lines will be shown per page, but
  633. a # in column 1 will force a new page.
  634.  
  635.  
  636.  
  637.  
  638. ----------------------------------------------------------------------------
  639.  
  640.                                CHAPTER NINE
  641.  
  642. ----------------------------------------------------------------------------
  643.  
  644. Future versions
  645.  
  646. There  is obviously a lot of development potential in this program, but new
  647. versions can only be produced if there is user support. Otherwise, I  shall
  648. have to concentrate on other products.
  649.  
  650. I  have  plans  to introduce on-screen help with COBOL syntax and statement
  651. formats, so that if you are unsure of any of the variants of, for  example,
  652. the UNSTRING statement, you can display a template.
  653.  
  654. Extra validation could be introduced. At present, it is possible to
  655. generate an IF structure without a condition, or a READ without the
  656. filename. This could be prevented by extra checking.
  657.  
  658. I could also develop a PC-specific version, written in C and using the full
  659. PC   screen  display  facilities.   Even,  perhaps,  a Windows version. The
  660. current program is itself written in structured  COBOL,  which  produces  a
  661. larger  than necessary EXE file, partly because COBOL does not have dynamic
  662. allocation of working storage.
  663.  
  664. Please support me with your registrations if you would like  to  see  these
  665. or any other improvements which you can suggest.
  666.  
  667.  
  668.  
  669. ----------------------------------------------------------------------------
  670.  
  671.                                    APPENDIX A
  672.  
  673. ----------------------------------------------------------------------------
  674.  
  675. Reformatting table definition
  676. -----------------------------
  677.  
  678. See COBFORM Manual
  679.  
  680.  
  681.  
  682. ----------------------------------------------------------------------------
  683.  
  684.                                APPENDIX B.
  685.  
  686. ----------------------------------------------------------------------------
  687.  
  688. Structure syntax  (MODE=S only)
  689. -------------------------------
  690.  
  691. PROC command
  692. ------------
  693.  
  694. SYNTAX:
  695.  
  696.       PROC procname
  697.       PROCBEGIN
  698.            procedure-body
  699.       PROCEND
  700.  
  701. Notes:
  702.  
  703. a) Structure commands may be in COBOL margin A or B
  704. b) procname must be valid for a COBOL section name
  705. c) procedure-body is an interation and/or a nest of structures
  706.  
  707. This command generates a COBOL section containing the specified structures.
  708.  
  709.  
  710. EXAMPLE:
  711.  
  712.        PROC A-MAIN PROCBEGIN
  713.             OPEN INPUT INFILE
  714.             PERFORM B-PROCESS
  715.             CLOSE INFILE
  716.             STOP RUN
  717.  
  718.        PROCEND
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726. IPROC command
  727. -------------
  728.  
  729. SYNTAX:
  730.  
  731. a) Inverted routine
  732.  
  733.     IPROC procname
  734.     PSVNAME numeric-item
  735.     PROCBEGIN
  736.         procedure-body
  737.     PROCEND
  738.  
  739.  
  740. b) Multithread routine
  741.  
  742.     IPROC procname
  743.     PSVNAME numeric-array
  744.     PSVTHREAD numeric-item
  745.     PROCBEGIN
  746.         procedure-body
  747.     PROCEND
  748.  
  749. Notes:
  750.  
  751. a) Structure commands may be in COBOL margin A or B
  752. b) procname must be valid for a COBOL section name
  753. c) procedure-body is an interation and/or a nest of structures
  754. d) numeric-item is used as a state variable or as an array index
  755. e) numeric-array is an array of state variables
  756.  
  757. This command generates a multi-state routine, which may be either
  758. single-thread or multi-thread depending on whether a PSVTHREAD is
  759. specified.
  760.  
  761. The multi-state technique is illustrated in the example BINTREE.STR
  762. where it is used for creating a binary tree.
  763.  
  764.  
  765.  
  766.  
  767.  
  768. RPROC command - Recursive procedure
  769. -----------------------------------
  770.  
  771. SYNTAX:
  772.  
  773.     RPROC procname
  774.     PSVNAME numeric-array
  775.     PSVTHREAD numeric-item
  776.     PROCBEGIN
  777.         procedure-body
  778.     PROCEND
  779.  
  780. Notes:
  781.  
  782. a) Structure commands may be in COBOL margin A or B
  783. b) procname must be valid for a COBOL section name
  784. c) procedure-body is an interation and/or a nest of structures
  785. d) numeric-item is used as a stack pointer
  786. e) numeric-array is an array of state variables, used as a stack
  787.  
  788. This generates a recursive routine. Examples are given in BINTREE.STR
  789. and FACTORL.STR
  790.  
  791. The subcommand RCALL may be used only within a recursive procedure,
  792. and performs the recursion.
  793.  
  794.  
  795.  
  796. SEQUENCE structure
  797. ------------------
  798.  
  799. This contains a structure body which is always obeyed once.
  800.  
  801. The body may contain any mix of COBOL statements and structures.
  802.  
  803. EXAMPLE:
  804.  
  805.     SEQUENCE
  806.         MOVE 1 TO WS-COUNT
  807.         ITERUNTIL WS-COUNT = 10
  808.         BEGIN
  809.             PERFORM DA-PROCESS
  810.             ADD 1 TO WS-COUNT
  811.         REPEAT
  812.         DISPLAY "FINISHED"
  813.     FI
  814.  
  815.  
  816. For further examples, see BINTREE.STR supplied with the software.
  817.  
  818.  
  819.  
  820.  
  821. SELECT structure
  822. ----------------
  823.  
  824. This selects one of a number of alternatives for execution. Up to 9999
  825. different cases may be specified.
  826.  
  827. It is also possible to supply a code body which is executed of none of the
  828. selection conditions are true, by giving a null condition.
  829.  
  830. EXAMPLE
  831.  
  832.     SELECT
  833.     CASE X = 1 BEGIN
  834.        PERFORM EA-TYPE-1
  835.     CASE X = 2 BEGIN
  836.        PERFORM EA-TYPE-2
  837.     CASE A = "STOP"
  838.           OR "HALT"
  839.     BEGIN
  840.        PERFORM EA-STOP
  841.     CASE BEGIN
  842.        PERFORM FA-ERROR
  843.     FI
  844.  
  845. Notes:
  846.  
  847. a) Only one of the alternatives is obeyed
  848. b) The condition can be any valid COBOL condition, including the use of
  849.    AND and OR.
  850. c) The condition MUST be terminated by the word BEGIN. Omitting this
  851.    is the most common cause of error.
  852. d) You can use CASE BEGIN, ie a null condition, instead of OTHERWISE.
  853.  
  854.  
  855.  
  856.  
  857. POSIT structure
  858. ----------------
  859.  
  860. This structure is included to facilitate backtracking and error handling.
  861.  
  862. It allows control to be transferred from any point within the POSIT
  863. body (or within any enclosed structure) to the associated ADMIT body.
  864. It is in fact a controlled GO TO function, which can avoid deep nesting
  865. of IF statements in many cases.
  866.  
  867. EXAMPLE:
  868.  
  869.     POSIT
  870.         MOVE 1 TO I
  871.         ITERUNTIL I  MAX
  872.         BEGIN
  873.            IF ITEM(I) = "AA10" QUIT
  874.            IF ITEM(I) = "CD30" QUIT
  875.            ADD 1 TO I
  876.         REPEAT
  877.         MOVE 0 TO FOUND
  878.     ADMIT
  879.         MOVE 1 TO FOUND
  880.     FI
  881.  
  882.  
  883. Notes:
  884.  
  885. a) There is no need to put a full stop after the word QUIT. One will
  886. be inserted.
  887. b) The ADMIT will ONLY be obeyed if a QUIT is executed.
  888. c) Any number of QUITs may be coded within the POSIT body or within
  889. any enclosed structure.
  890.  
  891.  
  892.  
  893.  
  894. ITERWHILE and ITERUNTIL structures
  895. ----------------------------------
  896.  
  897. These allow repeated execution of selected code. The condition is
  898. always evaluated at the START of the loop, allowing for the loop executed
  899. zero times ie not at all, if the condition should so indicate. The
  900. body may contain any mix of COBOL statements and structures.
  901.  
  902. EXAMPLE:
  903.  
  904.     MOVE 0 TO WS-EOF  WS-COUNT
  905.     READ INFILE AT END MOVE 1 TO WS-EOF.
  906.     ITERUNTIL  WS-EOF = 1 ( or ITERWHILE WS-EOF = 0)
  907.     BEGIN
  908.         PERFORM DA-PROCESS
  909.         ADD 1 TO WS-COUNT
  910.         READ INFILE AT END MOVE 1 TO WS-EOF.
  911.     REPEAT
  912.     DISPLAY WS-COUNT " records processed"
  913.  
  914. In this example, a "read-ahead" is performed before entering the main
  915. loop. This ensures that the routine works even if there are no records
  916. on the input file, and that it correctly counts the number of records
  917. read.
  918.  
  919. The use of "read-ahead" is strongly recommended, even when not strictly
  920. necessary, as it can often simplify code, and prevents the occurrence
  921. of some types of common logic error.
  922.  
  923. For further examples of the SELECT structure, see BINTREE.STR supplied
  924. with the software.
  925.  
  926. Notes:
  927.  
  928. a) A full stop is necessary after any conditional clause, eg AT END,
  929. ON OVERFLOW, etc.
  930. b) The condition may be any valid COBOL condition, and MUST be terminated
  931. by the word BEGIN
  932.  
  933.  
  934.  
  935. Minor commands
  936. --------------
  937.  
  938. Pseudo-read and write
  939. ---------------------
  940.  
  941. SREAD and SWRITE are synonymous, and perform pseudo-read (or pseudo-write)
  942. operations.
  943.  
  944. They are valid only within an IPROC. The action is to save a note
  945. of the current address in a state variable and exit from the routine.
  946. When the routine is reentered, processing resumes at the next instruction
  947. rather than at the start.
  948.  
  949. See PROC BA-BUILD-TREE in BINTREE.STR for a good example
  950.  
  951.  
  952.  
  953. RCALL - Recursive call
  954. ----------------------
  955.  
  956. RCALL performs a recursive call, and is valid only in an RPROC.
  957.  
  958. It saves the current address in a stack of state variables, increments
  959. the stack pointer, and starts again at the beginning of the procedure.
  960. At the end of the procedure, the stack is unwound, and processing
  961. resumes at the previous level of the stack.
  962.  
  963. Examples are to be found in both FACTORL.STR and BINTREE.STR
  964.  
  965.  
  966. Tailoring the language
  967. ----------------------
  968.  
  969. The structure commands are not actioned until after the textual replacement
  970. so you can replace any structure command by a word of your own choice.
  971.  
  972. For example, you could use WHEN instead of CASE, DO instead of BEGIN,
  973. and WEND instead of FI.
  974.  
  975. If you prefer abbreviations, how about ? for SELECT, [ for ITERWHILE,
  976. ] for repeat, and ! for BEGIN.
  977.  
  978. The only thing to watch is for possible conflicts with COBOL. For
  979. example, it is not a good idea to use UNTIL, because this would preclude
  980. the use of PERFORM ... UNTIL .
  981.  
  982.  
  983.  
  984.  
  985. ----------------------------------------------------------------------------
  986.  
  987. APPENDIX C.
  988.  
  989. ----------------------------------------------------------------------------
  990.  
  991. Example of structured program
  992. -----------------------------
  993.  
  994. Please see programs BINTREE.STR and FACTORL.STR on the disk. There didn't
  995. seem to be much point in including them here as well!
  996.  
  997.  
  998.  
  999. ----------------------------------------------------------------------------
  1000.  
  1001. APPENDIX D.
  1002.  
  1003. ----------------------------------------------------------------------------
  1004.  
  1005.  
  1006. Keyboard facilities.
  1007. --------------------
  1008.  
  1009. This program uses our ASK_MESSAGE emulator subroutine for formatted screen
  1010. handling.
  1011.  
  1012. The key functions follow, as far as practicable, the ICL terminals used for
  1013. VME MAC. Data can only be entered in unprotected fields, delimited by right
  1014. pointing triangle (start of unprotected) and left-pointing triangle.
  1015.  
  1016. The following keys have special functions:
  1017.  
  1018.     ESC          Immediately terminates the program with the display
  1019.                  "ESCAPED". The screen is NOT cleared.
  1020.  
  1021.     Home         Moves the cursor to the SOM (Start of Message marker)
  1022.                  This is usually the first unprotected field on the screen
  1023.  
  1024.     TAB          Tab to next unprotected field
  1025.     Shift + TAB  Tab to previous unprotected field (BackTab)
  1026.  
  1027.                  These cycle from end to start of screen if necessary
  1028.  
  1029.     PGUP, PGDN   Not used
  1030.  
  1031.     F1           Insert line (emulates  CTRL+INS)
  1032.     F2           Delete line (emulates  CTRL+DEL)
  1033.     F5           May be used to enter almost any non-keyboard character. It
  1034.                  should be followed by the 3-digit ASCII number for the
  1035.                  character.
  1036.                  The number must be in the range 032 to 255, as 0 to 32 are
  1037.                  reserved for program use. See also F10
  1038.     F4           )
  1039.     F6           )   Special record and play facilities - see Chapter 3
  1040.     F7           )
  1041.     F8           )
  1042.     F9           Configuration menu. At this release, it only allows
  1043.                  colours to be changed. The new colours can be saved into a
  1044.                  configuration file.
  1045.     F10          Character selection. A menu is displayed which allows
  1046.                  easy selection of most non-keyboard characters.
  1047.  
  1048. Note that only the text from the SOM (Start of Message) to the cursor is
  1049. used by the program. This is for compatibility with the Mainframe version
  1050. of the program. On a Colour screen, the SOM is marked with a red
  1051. background.
  1052.  
  1053. If the cursor is sent to the SOM by using the Home key, then the whole
  1054. screen is sent.
  1055.  
  1056.  
  1057.